package cn.zwxky.android.user.Search;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;

import com.zgscwjm.lsfbbasetemplate.Event.EventAnnotation;
import com.zgscwjm.lsfbbasetemplate.LsfbActivity;
import com.zgscwjm.lsfbbasetemplate.annotation.ContentView;
import com.zgscwjm.lsfbbasetemplate.annotation.OnClick;
import com.zgscwjm.lsfbbasetemplate.annotation.ViewInject;
import com.zgscwjm.lsfbbasetemplate.config.Config;
import com.zgscwjm.lsfbbasetemplate.internet.BaseInternet;
import com.zgscwjm.lsfbbasetemplate.utils.SN;

import java.util.HashMap;

import cn.zwxky.android.user.R;
import cn.zwxky.android.user.Utils.LittleUtils;
import cn.zwxky.android.user.Utils.Permission;
import cn.zwxky.android.user.Utils.URLString;

/**
 * 业务详情
 * Created by Administrator on 2017/3/21 0021.
 */
@ContentView(R.layout.aty_business_details)
public class BusinessDetailsActivity extends LsfbActivity {

    private String id="";

    /**
     * 标题
     */
    @ViewInject(R.id.item_business_details_text_title)
    private TextView text_title;

    /**
     * 负责人
     */
    @ViewInject(R.id.item_business_details_text_people)
    private TextView text_people;

    /**
     * 当前阶段
     */
    @ViewInject(R.id.bubble_tv2)
    private TextView bubble_tv2;

    /**
     * 下一阶段
     */
    @ViewInject(R.id.bubble_tv4)
    private TextView bubble_tv4;

    private String phone;


    @Override
    public void initView() {
        LittleUtils.setsimpletitlebar(this, "详情");
        Permission permission=new Permission(this);
        permission.GetcallPermission();
        id=getIntent().getStringExtra("id");

    }

    @Override
    public void initEvent() {

    }

    /**
     * 点击事件
     * @param view
     */
    @OnClick({R.id.aty_business_details_img_phone})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.aty_business_details_img_phone:
                startActivity(new Intent(
                        "android.intent.action.CALL", Uri.parse("tel:"
                        + phone)));
                break;
        }
    }

    @Override
    public void initData() {
        getData();
    }

    public void getData(){
        HashMap<String, String> hashMap = new HashMap<String, String>();
           hashMap.put("uid", Config.getUserId());
           hashMap.put("id", id);

        new BaseInternet().getData_Get(URLString.SERVICE_INFO, hashMap, BusinessDetailsBean.class, new BusinessDetailsEvent<BusinessDetailsBean>(), true,true);
    }

    @EventAnnotation
    public void BusinessDetailsEvent(BusinessDetailsEvent<BusinessDetailsBean> event){
        switch (event.getCode()){
            case 200:
                phone=event.getData().getTel();
                text_title.setText(event.getData().getTitle());
                text_people.setText("负责人："+event.getData().getName());
                bubble_tv2.setText(event.getData().getContent1());
                bubble_tv4.setText(event.getData().getContent2());
                break;
            default:
                SN.SnackShow(text_title,event.getMsg());
                break;
        }
    }

}
